package org.cqut.system.course.schedule;

import cn.hutool.core.thread.ThreadUtil;
import org.cqut.system.course.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author XiAoXu
 * @date 2021/11/16 21:17
 * @description
 */
@Component("courseSchedule")
@EnableScheduling
public class CourseSchedule {
    @Autowired
    private CourseService courseService;

    @Scheduled(cron = "0 0 0 */1 * ?")//每天0点执行
//    @Scheduled(cron = "0/5 * * * * ?")//每5秒执行
    public void checkNotice() {
        ThreadUtil.execAsync(() -> courseService.courseIsEnd());
    }
}
